perm filename PARFNS.DOC[4,KMC] blob sn#125309 filedate 1975-09-17 generic text, type T, neo UTF8
There are two programs related to the PARRY pattern tables:
a SAIL program, SETUP.SAI[HMF,RCP], and a FAIL program, PARFNS.FAI[HMF,RCP].

SETUP reads in four files: the PARRY synonym dictionary, dictionaries of
simple and complex patterns, and a key/disk-location file related to PARRY's
English responses. From these, it generates files which are in a dump format
suitable for read-in by PARFNS, which runs in LISP binary program space. Examples
of the expected formats of the four SETUP input files are as follows:

THE SYNONYM FILE:

	(HOSPITAL HOSPI)
	(RACETRACK RACES)


THE SIMPLE AND COMPLEX PATTERN FILES:

	((BE YOU HOSPI) λ0050)
	((P1234 λ4321 λ8765) λ5678)
	

THE DISK LOCATIONS FILE

	(λ0028 . 00001057634)

All atoms except the left members of the synonym file must be 5 character or less,
and the current upper limit on pattern lengths is 10, although this is alterable
without much grief. All files are assumed to be sorted in ascending ASCII order.
SETUP doesn't care, but PARFNS won't work right because it uses a binary lookup
algorithm. "SSORT" is a system program which will sort these files for you. The
numbers in the disk locations file are assumed to be in octal.

Items in these four input files which do not conform to these specifications are
written (as they appeared) onto an exception file. The input, output and exception
files which SETUP uses are listed by SETUP before it begins, and may be changed
before giving SETUP the go-ahead. SETUP is pretty much self-explanatory, and is
run by "EX SETUP.SAI[HMF,RCP]".
The four dump files produced as output are the input to PARFNS. All have the same
format which is as follows:

		WORD 0: 0
		WORD 1: LENGTH 1 PATTERN TABLE START ADDRESS
		  .
		  .
		  .
		WORD 10: LENGTH 10 PATTERN TABLE START ADDRESS
		WORD 11: TOTAL SPACE WHICH WILL BE REQUIRED BY ALL TABLES
		WORDS 12 THRU 127: 0

The START ADDRESSES are relative to the origin of the start of the second physical
disk record, namely word 128 (200 octal) of the file. START_ADDRESS(N) = 0
indicates that are no patterns, hence no tables, of length N.

The pattern table for patterns of length L has the following format:

		WORD 0: THE NUMBER OF PATTERNS, N, IN THIS TABLE
			(NOT COUNTING THIS WORD) IN THE LEFT HALF, THE ORIGIN
			OF THE VALUE TABLE ASSOCIATED WITH THESE PATTERNS (WORD
			N*L+1).
		WORDS 1 THRU N: ELEMENT 1 OF PATTERNS (UP TO 5 ASCII CHARACTERS)
		WORDS N+1 THRU 2N: ELEMENT 2 OF PATTERNS
		 ...
		WORDS N*(L-1)+1 THRU N*L: ELEMENT L OF PATTERNS
		WORD N*L+1: 0 (THE START OF THE VALUE TABLE)
		WORDS N*L+2 THRU N*(L+1)+1: VALUES FOR PATTERNS IN THE TABLE

The pattern tables are distinguished by pattern length to optimize storage use:
the table containing N patterns of length L occupies N*(L+1)+2 machine words. The
synonym tables are stored and accessed identically to the simple and complex
pattern tables: the English word whose synonym is desired is simply viewed as a
sequence of 5-character atoms. The disk-locations table is treated like patterns
of length 1.
PARFNS is the FAIL package which contains the following functions (among others):

	(SYNNYM X)  If it can be found, return X's synonym as a single-membered
		    list, NIL otherwise.

	(SPAT P)    If pattern P (a list of atoms) can be located in the simple
		    pattern tables, return its value as an atom, otherwise NIL

	(CPAT P)    If pattern P (a list of atoms) can be located in the complex
		    pattern tables, return its value as an atom, otherwise NIL

	(STHGHT V)  STHGHT is the inverse of SPAT: V is assumed to be a pattern
		    name (number) for which a list of all associated patterns is
		    desired. If patterns can be found, they are returned as a list.
		    Otherwise NIL is returned.

	(CTHGHT V)  Similar to STHGHT, except that lookup occurs in the complex
		    pattern tables.

	(DSKLOC V)  If there is a disk location associated with V, return it as
		    a LISP number. Otherwise return NIL.

The following 4 functions are called automatically, when needed.

	(INSYN)     Acquires space from LISP binary program space, using but not
		    updating BPORG, and checking against BPEND for potential
		    overflow. If space is available, INSYN reads in the synonym
		    dump file created by the SAIL program, then initializes it.
		    The file is currently assumed to be SYNONM.PAR.
		    INSYN may be executed repeatedly. WARNING: INSYN assumes
		    that the first property on BPEND's property list is the
		    VALUE property. Other properties should therefore not be
		    associated with BPEND.

	(INSPAT)    Same as INSYN, except that these initialize the simple pattern
	(INCPAT)    complex pattern and disk locations table files, respectively.
	(INDSKL)    These files are currently assumed to be SPATS.PAR, CPATS.PAR
		    and PDATX.PAR.


The SAIL program, SETUP, will indicate the total number (octal) of words, T, the
three dump files will occupy in binary program space when PARFNS reads them in.
The LISP core image should therefore be allocated this amount of BPS plus the amount
of space required for the PARFNS program, currently less than 1000 (octal) words.

To set up the LISP core image with the PARFNS routines, DO PARFNS.DO[HMF,RCP].
	OPTIONS WITHIN PARFNS:

DEFAULT			OPTION			CRITERIA		FLAG
---------------------------------------------------------------------------------
ALL.PAR			SYNONM.PAR		ALL.PAR not found	MULTFL
			SPATS.PAR					ALLOPN
			CPATS.PAR
			PDATX.PAR
---------------------------------------------------------------------------------
[1,3]			[PAR,RCP]		user is RCP		PPN
---------------------------------------------------------------------------------
all at once		overlaid		BP space full		OVERLA
---------------------------------------------------------------------------------
table index out		table index in core	data needed		ITxxxx
---------------------------------------------------------------------------------
table out		table in core		data needed		Ixxxx